public class Draw {
    private int height;
    public Draw(int height){
        if(height <=3){
            System.out.println("Height cannot be less than 3");
        }
        else{
            this.height = height;
        }
    }

    public void drawTriangle(){
        for(int i=0;i<height;i++) {
            for (int j = 1; j <= (2 * height - 1 - (2 * i + 1)) / 2; j++) {
                System.out.print(" ");//不使用System.out.println()，会换行
            }
            for (int k = 1; k <= 2 * i + 1; k++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }

    public void drawRectangle(int length){
        int effectiveLength = Math.max(2,length);
        for(int i=0;i<height;i++){
            for(int j = 1; j<=effectiveLength;j++){
                System.out.print("*");
            }
            System.out.println();
        }
    }

    public void drawSquare(){
        for(int i=0;i<height;i++) {
            for (int j = 1; j <= 2*height-1; j++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }

    public void drawParallelogram(int length){
        int effectiveLength = Math.max(2, length);
        for(int i=0;i<height;i++) {
            for(int j = 1; j<=height-1-i;j++){
                System.out.print(" ");
            }
            for(int k = 1; k<=effectiveLength;k++){
                System.out.print("*");
            }
            System.out.println();
        }
    }

    public static void main(String[] args){
        Draw Draw1 = new Draw(4);
        Draw1.drawTriangle();
        Draw Draw2 = new Draw(4);
        Draw2.drawRectangle(3);
        Draw Draw3 = new Draw(4);
        Draw3.drawSquare();
        Draw Draw4 = new Draw(4);
        Draw4.drawParallelogram(1);
    }
}
